﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Editor.PageControls;
using Editor.Utilities;

namespace Editor
{
    public partial class AddFormBase : Form
    {
        private int previouslySelectedIndex = 0;

        public AddFormBase()
        {
            InitializeComponent();
        }

        public virtual PageControl CreatedControl { get; set; }

        protected void resetSubject()
        {
            previouslySelectedIndex = EditorForm.CurrentLanguageIndex;
        }

        protected T changeSubject<T>(string lang, int newIndex, T subject, ref SDictionary<T> dict)
        {
            dict[EditorForm.SupportedLanguages[previouslySelectedIndex]] =
                subject;

            T result;

            if (dict.ContainsLanguage(lang))
                result = dict[lang];
            else
                result = default(T);

            previouslySelectedIndex = newIndex;

            return result;
        }

        private void CreateFormBase_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == System.Windows.Forms.DialogResult.Retry)
                e.Cancel = true;
        }
    }
}
